<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<!DOCTYPE html>
<html>
<head>
<title>新闻栏目</title>
<%@ include file="/WEB-INF/views/manager/include.inc.jsp"%>
<link rel="stylesheet" href="${contextPath }/styles/zTree/css/zTreeStyle/zTreeStyle.css">
</head>
<body>
<!--top s-->
<c:import url="/public/header?tag=Config" />
<!--top end-->
<div class="m_main">
  <!--left s-->
  <c:import url="/public/left?tag=Config&tag1=ArticleColumn" />
  <!--left end-->
  <!--right s-->
  <div class="m_right fl">
    <div class="r_box">
	  <div class="title1"><h3>新闻栏目</h3></div>
	  <div class="btnbox">
		<shiro:hasPermission name="ArticleColumn:save">
		  <input name="" type="button" class="btnbase fl" value="新 增" onclick="location.href='${contextPath }/manager/article/column/create'" />
	    </shiro:hasPermission>
		<shiro:hasPermission name="ArticleColumn:save">
		  <input name="" type="button" class="btnbase fl" value="删 除" onclick="deleteColumn()" />
	    </shiro:hasPermission>
	  </div>
	  <div class="tree_box ovh">
        <div class="wid fl">
  		  <ul id="treeDemo" class="ztree"></ul>
        </div>
	  </div>
    </div>
  </div>
  <!--right end-->
</div>
<div class="foot"></div>
<script src="${contextPath }/styles/zTree/jquery.ztree.core.js"></script>
<script src="${contextPath }/styles/zTree/jquery.ztree.excheck.js"></script>
<script>
function close2refresh() {
	goToPage(path + "/manager/article/column/list");
}
function deleteColumn() {
	if (confirm("确定要删除吗？")) {
		var id_array = onCheck();
		//console.log(id_array.join(","));
		$.post2("${contextPath}/manager/article/column/delete/", {ids: id_array}, callbackRef, "json");
	}
}
function onCheck(){
	var zTree = $.fn.zTree.getZTreeObj("treeDemo");
	var nodes = zTree.getCheckedNodes(true);
	var id_array = [];
	for (var i=0; i<nodes.length; i++) {
		if (!nodes[i].getCheckStatus().half)
			id_array.push(nodes[i].id);
	}
	return id_array;
}
$(function(){
	var setting = {
		check: { enable: true, chkStyle: "checkbox", chkboxType: { "Y": "ps", "N": "ps" }},
		view: { dblClickExpand: false },
		data: { simpleData: { enable: true } },
		callback: { 
			onClick: function(e, treeId, treeNode, isClick) {
				goToPage(path + "/manager/article/column/update/" + treeNode.id);
			}
		}
	};
	var zTree = $.fn.zTree.init($("#treeDemo"), setting, JSON.parse('${columnList}'));
	zTree.expandAll(true);
	var nodes = '${columnList}';
	if (nodes) {
		$(nodes.split(",")).each(function(n, value){
			var node = zTree.getNodeByParam("code", "" + this, null);
			node && zTree.checkNode(node, true);
		});
	}
});
</script>
</body>
</html>